package impl.sdi.business;

import impl.sdi.business.classes.cat.CatAlta;
import impl.sdi.business.classes.cat.CatBaja;
import impl.sdi.business.classes.cat.CatBuscar;
import impl.sdi.business.classes.cat.CatListado;
import impl.sdi.business.classes.cat.CatUpdate;


import java.util.List;

import com.sdi.business.CatService;
import com.sdi.business.exception.EntityAlreadyExistsException;
import com.sdi.business.exception.EntityNotFoundException;
import com.sdi.model.Categoria;


public class SimpleCatService implements CatService {

	public List<Categoria> getCategorias() {
		return new CatListado().getCategorias();
	}

	@Override
	public void saveCategoria(Categoria cat) throws EntityAlreadyExistsException {
		new CatAlta().save(cat);
	}

	@Override
	public void updateCategoria(Categoria cat) throws EntityNotFoundException {
		new CatUpdate().update(cat);
	}

	@Override
	public void deleteCategoria(String name) throws EntityNotFoundException {
		new CatBaja().delete(name);
	}

	@Override
	public Categoria findByName(String name) throws EntityNotFoundException {
		return new CatBuscar().find(name);
	}
}
